package manager

import (
	"fmt"
	"github.com/topfreegames/pitaya/fairy/pojo"
	"github.com/topfreegames/pitaya/lock"
	"sync"
)

var (
	GuidGeneratorManager *guidGeneratorManager
	guidGeneratorOnce sync.Once
)


type guidGeneratorManager struct {
	BaseManager
	redisLocks map[int]*lock.RedisLock
}

func NewGuiGeneratorManager() *guidGeneratorManager {
	guidGeneratorOnce.Do(func() {
		length := pojo.GuidTypeRedPacket - pojo.GuidTypePlayer
		GuidGeneratorManager = &guidGeneratorManager{redisLocks:make(map[int]*lock.RedisLock,length)}

		for i := pojo.GuidTypePlayer;i<=length;i++{
			GuidGeneratorManager.redisLocks[int(i)] = lock.NewRedisLock(fmt.Sprintf("guid_type_%d",i))
		}
	})
	return GuidGeneratorManager
}






